home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-12-14 | 3.3 KB | 136 lines | [TEXT/CWIE] |
- ///--------------------------------------------------------------------------------------
- // SWApplication.c
- //
- // Portions are Copyright: © 1993 Tony Myles, All rights reserved worldwide.
- ///--------------------------------------------------------------------------------------
-
- #ifndef __SPRITEWORLD__
- #include "SpriteWorld.h"
- #endif
-
- #include <Gestalt.h>
- #include "SWApplication.h"
-
- // The user can put a pointer to their SpriteWorld here, allowing FatalError()
- // to remove the VBL task, if any, before quitting.
- extern SpriteWorldPtr gCleanUpSpriteWorldP;
-
-
- ///--------------------------------------------------------------------------------------
- // Initialize
- ///--------------------------------------------------------------------------------------
-
- void Initialize(short numberOfMasters)
- {
- EventRecord tempEvent;
-
- MaxApplZone();
-
- while (numberOfMasters--)
- {
- MoreMasters();
- }
-
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NULL);
- InitCursor();
- FlushEvents(everyEvent, 0);
-
- (void)EventAvail(everyEvent, &tempEvent);
- (void)EventAvail(everyEvent, &tempEvent);
- (void)EventAvail(everyEvent, &tempEvent);
- }
-
-
- ///--------------------------------------------------------------------------------------
- // ReportError
- ///--------------------------------------------------------------------------------------
-
- void ReportError(OSErr err, char* filename, int lineNumber)
- {
- SetCursor(&qd.arrow);
- ShowCursor();
-
- if (err == memFullErr)
- {
- ErrorAlert(err, filename, lineNumber, kOutOfMemoryStringIndex);
- }
- else if (err == resNotFound)
- {
- ErrorAlert(err, filename, lineNumber, kCantFindResourceStringIndex);
- }
- else
- {
- ErrorAlert(err, filename, lineNumber, kFatalErrorStringIndex);
- }
- }
-
-
- ///--------------------------------------------------------------------------------------
- // DoCantFindResource
- ///--------------------------------------------------------------------------------------
-
- void DoCantFindResource( char* filename, int lineNumber )
- {
- OSErr err;
-
- err = ResError();
-
- if (err == noErr)
- {
- err = resNotFound;
- }
-
- ErrorAlert(err, filename, lineNumber, kCantFindResourceStringIndex);
- }
-
-
- ///--------------------------------------------------------------------------------------
- // ErrorAlert
- ///--------------------------------------------------------------------------------------
-
- void ErrorAlert(OSErr err, char* filename, int lineNumber, short errorStringIndex)
- {
- Str255 messageString, errorString, fileString = "\p", lineString;
- short n;
-
- GetIndString(messageString, kErrorStringListResID, errorStringIndex);
-
- if (messageString[0] == 0)
- {
- BlockMove(kSeriousDamageString, messageString, sizeof(kSeriousDamageString));
- }
-
- for (n = 0; filename[n] != 0; n++)
- {
- fileString[n+1] = filename[n];
- }
- fileString[0] += n;
-
- NumToString(err, errorString);
- NumToString(lineNumber, lineString);
- ParamText(messageString, fileString, lineString, errorString);
-
- (void)StopAlert(kErrorAlertResID, NULL);
-
- if (gCleanUpSpriteWorldP != NULL)
- SWSyncSpriteWorldToVBL(gCleanUpSpriteWorldP, false);
-
- ExitToShell();
- }
-
-
- ///--------------------------------------------------------------------------------------
- // CantRunOnThisMachine
- ///--------------------------------------------------------------------------------------
-
- void CantRunOnThisMachine( void )
- {
- (void)StopAlert(kCantRunAlertResID, NULL);
- }
-
-